PROP_HAS_SELECTION,
PROP_CURSOR_POSITION,
PROP_COPY_TARGET_LIST,
- PROP_PASTE_TARGET_LIST
+ PROP_PASTE_TARGET_LIST,
+ LAST_PROP
};
static void gtk_text_buffer_finalize (GObject *object);
GParamSpec *pspec);
static guint signals[LAST_SIGNAL] = { 0 };
+static GParamSpec *text_buffer_props[LAST_PROP];
G_DEFINE_TYPE_WITH_PRIVATE (GtkTextBuffer, gtk_text_buffer, G_TYPE_OBJECT)
klass->mark_set = gtk_text_buffer_real_mark_set;
/* Construct */
- g_object_class_install_property (object_class,
- PROP_TAG_TABLE,
- g_param_spec_object ("tag-table",
- P_("Tag Table"),
- P_("Text Tag Table"),
- GTK_TYPE_TEXT_TAG_TABLE,
- GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- /* Normal properties*/
-
+ text_buffer_props[PROP_TAG_TABLE] =
+ g_param_spec_object ("tag-table",
+ P_("Tag Table"),
+ P_("Text Tag Table"),
+ GTK_TYPE_TEXT_TAG_TABLE,
+ GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ /* Normal properties */
+
/**
* GtkTextBuffer:text:
*
*
* Since: 2.8
*/
- g_object_class_install_property (object_class,
- PROP_TEXT,
- g_param_spec_string ("text",
- P_("Text"),
- P_("Current text of the buffer"),
- "",
- GTK_PARAM_READWRITE));
+ text_buffer_props[PROP_TEXT] =
+ g_param_spec_string ("text",
+ P_("Text"),
+ P_("Current text of the buffer"),
+ "",
+ GTK_PARAM_READWRITE);
/**
* GtkTextBuffer:has-selection:
*
* Since: 2.10
*/
- g_object_class_install_property (object_class,
- PROP_HAS_SELECTION,
- g_param_spec_boolean ("has-selection",
- P_("Has selection"),
- P_("Whether the buffer has some text currently selected"),
- FALSE,
- GTK_PARAM_READABLE));
+ text_buffer_props[PROP_HAS_SELECTION] =
+ g_param_spec_boolean ("has-selection",
+ P_("Has selection"),
+ P_("Whether the buffer has some text currently selected"),
+ FALSE,
+ GTK_PARAM_READABLE);
/**
* GtkTextBuffer:cursor-position:
*
- * The position of the insert mark (as offset from the beginning
- * of the buffer). It is useful for getting notified when the
+ * The position of the insert mark (as offset from the beginning
+ * of the buffer). It is useful for getting notified when the
* cursor moves.
*
* Since: 2.10
*/
- g_object_class_install_property (object_class,
- PROP_CURSOR_POSITION,
- g_param_spec_int ("cursor-position",
- P_("Cursor position"),
- P_("The position of the insert mark (as offset from the beginning of the buffer)"),
- 0, G_MAXINT, 0,
- GTK_PARAM_READABLE));
+ text_buffer_props[PROP_CURSOR_POSITION] =
+ g_param_spec_int ("cursor-position",
+ P_("Cursor position"),
+ P_("The position of the insert mark (as offset from the beginning of the buffer)"),
+ 0, G_MAXINT,
+ 0,
+ GTK_PARAM_READABLE);
/**
* GtkTextBuffer:copy-target-list:
*
* Since: 2.10
*/
- g_object_class_install_property (object_class,
- PROP_COPY_TARGET_LIST,
- g_param_spec_boxed ("copy-target-list",
- P_("Copy target list"),
- P_("The list of targets this buffer supports for clipboard copying and DND source"),
- GTK_TYPE_TARGET_LIST,
- GTK_PARAM_READABLE));
+ text_buffer_props[PROP_COPY_TARGET_LIST] =
+ g_param_spec_boxed ("copy-target-list",
+ P_("Copy target list"),
+ P_("The list of targets this buffer supports for clipboard copying and DND source"),
+ GTK_TYPE_TARGET_LIST,
+ GTK_PARAM_READABLE);
/**
* GtkTextBuffer:paste-target-list:
*
* Since: 2.10
*/
- g_object_class_install_property (object_class,
- PROP_PASTE_TARGET_LIST,
- g_param_spec_boxed ("paste-target-list",
- P_("Paste target list"),
- P_("The list of targets this buffer supports for clipboard pasting and DND destination"),
- GTK_TYPE_TARGET_LIST,
- GTK_PARAM_READABLE));
+ text_buffer_props[PROP_PASTE_TARGET_LIST] =
+ g_param_spec_boxed ("paste-target-list",
+ P_("Paste target list"),
+ P_("The list of targets this buffer supports for clipboard pasting and DND destination"),
+ GTK_TYPE_TARGET_LIST,
+ GTK_PARAM_READABLE);
+
+ g_object_class_install_properties (object_class, LAST_PROP, text_buffer_props);
/**
* GtkTextBuffer::insert-text:
_gtk_text_btree_insert (iter, text, len);
g_signal_emit (buffer, signals[CHANGED], 0);
- g_object_notify (G_OBJECT (buffer), "cursor-position");
+ g_object_notify_by_pspec (G_OBJECT (buffer), text_buffer_props[PROP_CURSOR_POSITION]);
}
static void
if (has_selection != buffer->priv->has_selection)
{
buffer->priv->has_selection = has_selection;
- g_object_notify (G_OBJECT (buffer), "has-selection");
+ g_object_notify_by_pspec (G_OBJECT (buffer), text_buffer_props[PROP_HAS_SELECTION]);
}
g_signal_emit (buffer, signals[CHANGED], 0);
- g_object_notify (G_OBJECT (buffer), "cursor-position");
+ g_object_notify_by_pspec (G_OBJECT (buffer), text_buffer_props[PROP_CURSOR_POSITION]);
}
static void
{
gtk_text_buffer_set_modified (buffer, TRUE);
- g_object_notify (G_OBJECT (buffer), "text");
+ g_object_notify_by_pspec (G_OBJECT (buffer), text_buffer_props[PROP_TEXT]);
}
static void
if (has_selection != buffer->priv->has_selection)
{
buffer->priv->has_selection = has_selection;
- g_object_notify (G_OBJECT (buffer), "has-selection");
+ g_object_notify_by_pspec (G_OBJECT (buffer), text_buffer_props[PROP_HAS_SELECTION]);
}
}
if (mark == insert)
- g_object_notify (G_OBJECT (buffer), "cursor-position");
+ g_object_notify_by_pspec (G_OBJECT (buffer), text_buffer_props[PROP_CURSOR_POSITION]);
}
static void